<?php

FLEA::loadClass('FLEA_Com_RBAC_UsersManager');

class Table_Members extends FLEA_Com_RBAC_UsersManager
{
	var $primaryKey = 'member_id';
	
	/**
	 * 定义members表与user_groups表的belongsTo关联
	 * 即每一个用户都属于唯一一个用户组
	 *
	 * @var array
	 */
	var $belongsTo = array(
         array(
             'tableClass'   => 'Table_UserGroups',
             'foreignKey'   => 'user_group_id',
             'mappingName'  => 'user_group',
         ),
     );

     /**
	 * 定义members表与permissions表以及的roles表的多对多关联
	 *
	 * @var array
	 */
    var $manyToMany = array(
    	array(
	        'tableClass'  => 'Table_Permissions',
	        'mappingName' => 'permissions',
	        'joinTableClass'   => 'Table_MembersHasPermissions',
    		'foreignKey' => 'member_id',
            'assocForeignKey' => 'permission_id',
    	),
    	array(
	        'tableClass'  => 'Table_Roles',
	        'mappingName' => 'roles',
	        'joinTableClass'   => 'Table_MemberHasRoles',
    		'foreignKey' => 'member_id',
            'assocForeignKey' => 'role_id',
    	),
    );

	function Table_Members($params = null){  
		$this->tableName = FLEA::getAppInf('WebsetupTablePrefix').'members';  
		parent::FLEA_Com_RBAC_UsersManager($params);  
	}
     
}

?>